<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    {include file="common/head" /}
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form action="" id="form" class="layui-form" method="post">
            <input type="hidden" name="id" value="{$info.id|default=0}">


            <div class="layui-form-item">
                <label for="title" class="layui-form-label">
                    <span class="x-red">*</span>服务名称
                </label>
                <div class="layui-input-inline">
                    <input type="text" value="{$info.title}" id="title" name="title" required="" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">

                </div>
            </div>

            {:getUploadImage($info['thumb_min'],'thumb_min','首页图片')}

            {:getUploadImage($info['thumb'],'thumb','服务图片')}


            <div class="layui-form-item">
                <label for="price" class="layui-form-label">
                    <span class="x-red">*</span>服务费金额
                </label>
                <div class="layui-input-inline">
                    <input type="text" value="{$info.price|default=0}" id="price" name="price" required="" lay-verify="required" lay-verify="zm" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">元</span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="mobile" class="layui-form-label">
                    <span class="x-red">*</span>服务电话
                </label>
                <div class="layui-input-inline">
                    <input type="text" value="{$info.mobile}" id="mobile" name="mobile" required="" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red"></span>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red"></span>类型</label>
                <div class="layui-input-block">
                    <input type="radio" name="type" value="0" {eq name="info['type']" value="0"}checked{/eq} lay-skin="primary" title="检车" checked="">
                    <input type="radio" name="type" value="1" {eq name="info['type']" value="1"}checked{/eq} lay-skin="primary" title="陪购">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red"></span>状态</label>
                <div class="layui-input-block">
                    <input type="radio" name="status" value="1" {eq name="info['status']" value="1"}checked{/eq} lay-skin="primary" title="显示" checked="">
                    <input type="radio" name="status" value="0" {eq name="info['status']" value="0"}checked{/eq} lay-skin="primary" title="隐藏">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>服务项目描述
                </label>
                <div class="layui-input-block">
                    {:getEditor($info['desc_content'],'desc_content',300)}
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>服务项目内容
                </label>
                <div class="layui-input-block">
                    {:getEditor($info['content'],'content')}
                </div>
            </div>

            <div class="layui-form-item">
                <label for="ok" class="layui-form-label">
                </label>
                <button id="ok" class="layui-btn" lay-filter="add" lay-submit="">
                    {empty name="info['id']"}
                    增  加
                    {else /}
                    修  改
                    {/empty}

                </button>
            </div>
        </form>
    </div>
</div>

<div id="idbox" style="display: none">

</div>
<script>layui.use(['form', 'layer'],
    function() {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;

        //自定义验证规则
        form.verify({
            zm: function(value) {
                if(!new RegExp("^[0-9.\s·]+$").test(value)){
                    return '只能是字母或数字，字母和下划线开头';
                }
            }
        });

        //监听提交
        form.on('submit(add)',
            function(data) {
                $.ajax({
                    type: "POST",
                    url: "{:url()}",
                    data: data.field,
                    success: function (result) {
                        layer.alert(result.msg, {
                            icon: 6
                        },function() {
                            xadmin.close();
                            xadmin.father_reload();
                        });
                    },
                    error: function(data) {
                        layer.alert(data.msg, {
                            icon: 2
                        },function() {
                            xadmin.close();
                        });
                    }

                });
                return false;
            });
    });
</script>

</body>

</html>
